package com.mxpio.erp.sales.service.impl;

import com.mxpio.erp.common.sales.entity.Customer;
import com.mxpio.erp.common.sales.service.CustomerService;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class CustomerServiceImpl extends BaseServiceImpl<Customer> implements CustomerService {

	@Override
	@Transactional(readOnly = false)
	public int assign(String username, String pnCodes) {
		Object[] pnCode = pnCodes.split(",");
		return JpaUtil.linu(Customer.class).set("bizMan", username).in("pnCode", pnCode).update();
	}

	@Override
	@Transactional(readOnly = false)
	public int transfer(String fromUser, String toUser) {
		return JpaUtil.linu(Customer.class).set("bizMan", toUser).equal("bizMan", fromUser).update();
	}
}
